# 下拉框处理
from selenium import webdriver
import time
import os
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
url = "file:///" + os.path.abspath("drop_down.html")
driver.get(url)
# 可以通过xpath定位到选择框的9.03
# driver.find_element_by_xpath("//*[@id='ShippingMethod']/option[4]")

time.sleep(5)
# 定位到下拉框
m = driver.find_element_by_id("ShippingMethod")
time.sleep(3)
# 点击下拉框的选项
m.find_element_by_xpath("//*[@id='ShippingMethod']/option[4]").click()


# 也可以通过标签定位到所有的option
# options = driver.find_element_by_tag_name("option")
# 遍历options数组，找到9.03的那个
# for option in options:
#     if option.get_attribute('value') == '9.03':
#        option.click()
# 也可以直接选择数组的第3个点击
# options[3].click()
time.sleep(5)
driver.quit()
